package com.credithc.customers.base.ro;

import com.credithc.customers.base.codes.CustomerCodes;
import com.credithc.customers.base.exception.CustomerException;
import com.credithc.customers.base.utils.CustomerUtils;
import lombok.Data;

/**
 * @Title:
 * @Author: Denghx
 * @Date: 2018/12/3 23:12
 * @Description: com.credithc.customers.api.ro
 * @Version: V1.0.0
 */
@Data
public class CustomerRelationDetailRo {

    private Integer customerProperty;

    private String customerNo;

    private Integer role;

    public static void checkBaseParam(CustomerRelationDetailRo ro) {
        CustomerUtils.checkCustomerNo(ro.getCustomerNo());
        Integer customerProperty = ro.getCustomerProperty();
        if (customerProperty == null) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "客户性质不能为空");
        } else if (!(customerProperty == 0 || customerProperty == 1)) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "客户性质只能为0或1");
        }
        Integer role = ro.getRole();
        if (role == null) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "客户关系类型不能为空");
        } else if (role < 0 || role > 10) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "客户关系类型只能为0-10");
        }
    }
}
